#ifndef __SEARCHENGINESERVER_H__
#define __SEARCHENGINESERVER_H__

#include "Thread.h"
#include "TcpConnection.h"
#include "TcpServer.h"
#include "RedisCache.h"
#include "ThreadPool.h"
#include "KeyRecommander.h"
#include "WebPageSearcher.h"
#include "WebPageQuery.h"

//#include "json.hpp"
#include <iostream>
//各个模块的头文件


class SearchEngineServer
{
public:
    SearchEngineServer(size_t threadNum,size_t queSize,const string &ip,short port);  //构造函数
    ~SearchEngineServer();
    void start();   //开始提供服务
    void stop();    //停止服务
private:
    void onConnection(const TcpConnectionPtr &conn);  //被注册回调函数，提供给TcpServer使用
    void onMessage(const TcpConnectionPtr & conn);    //被注册回调函数，提供给TcpServer使用
    void onClose(const TcpConnectionPtr & conn);      //被注册回调函数，提供给TcpServer使用

private:
    TcpServer _tcpServer;   //TCP通信模块
    ThreadPool _pool;       //线程池
    KeyRecommander _keyRecommander;      //关键字推荐模块
    WebPageSearcher _webSearcher;       //网页查询模块
    //Protocol Parser _protocolParser;   //协议解析模块

};

#endif
